package com.itheima.shuzu;

import java.util.Random;

public class Demo9 {
    public static void main(String[] args) {
        Random ran = new Random();
        int[] data = new int[7];
        for (int i = 0; i < data.length - 1; i++) {
            int c = ran.nextInt(32) + 1;
            int a = Demo9.caipiao(data, c);
            if (a != -1) {
                data[i] = c;
            } else {
                i--;
            }
        }
        data[data.length - 1] = ran.nextInt(32) + 1;
        System.out.println("红色的球编号有");
        for (int i = 0; i < data.length-1; i++) {
            System.out.print(data[i]+" ");
        }
        System.out.println("     ");
        System.out.println("蓝色的球编号有:"+data[data.length-1]);
    }

    public static int caipiao(int[] data, int a) {
        for (int i = 0; i < data.length; i++) {
            if (data[i] == a) {
                return -1;
            }
        }
        return a;
    }
}
